package cn.jboa.entity;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.sql.Time;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "BIZ_CLAIM_VOUCHER", schema = "SCOTT", catalog = "")
public class BizClaimVoucher {
    private int id;
    private Date createTime;
    private String event;
    private long totalAccount;
    private String status;
    private Date modifyTime;

    private SysEmployee creator;//创建者
    private SysEmployee nexDeal;//处理者

    private List<BizClaimVoucherDetail> detailList = new ArrayList<BizClaimVoucherDetail>();
    private List<BizCheckResult> checkResultList = new ArrayList<BizCheckResult>();

    @OneToMany(mappedBy = "claimVoucher",cascade = {CascadeType.ALL})
    public List<BizClaimVoucherDetail> getDetailList() {
        return detailList;
    }

    public void setDetailList(List<BizClaimVoucherDetail> detailList) {
        this.detailList = detailList;
    }

    @OneToMany(mappedBy = "checkEmployee",cascade = {CascadeType.ALL})
    public List<BizCheckResult> getCheckResultList() {
        return checkResultList;
    }

    public void setCheckResultList(List<BizCheckResult> checkResultList) {
        this.checkResultList = checkResultList;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="create_sn")
    public SysEmployee getCreator() {
        return creator;
    }

    public void setCreator(SysEmployee creator) {
        this.creator = creator;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="next_deal_sn")
    public SysEmployee getNexDeal() {
        return nexDeal;
    }

    public void setNexDeal(SysEmployee nexDeal) {
        this.nexDeal = nexDeal;
    }

    @GenericGenerator(name = "generator", strategy = "increment")
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name = "ID")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "CREATE_TIME")
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "EVENT")
    public String getEvent() {
        return event;
    }

    public void setEvent(String event) {
        this.event = event;
    }

    @Basic
    @Column(name = "TOTAL_ACCOUNT")
    public long getTotalAccount() {
        return totalAccount;
    }

    public void setTotalAccount(long totalAccount) {
        this.totalAccount = totalAccount;
    }

    @Basic
    @Column(name = "STATUS")
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Basic
    @Column(name = "MODIFY_TIME")
    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        BizClaimVoucher that = (BizClaimVoucher) o;

        if (id != that.id) return false;
        if (totalAccount != that.totalAccount) return false;
        if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false;
        if (event != null ? !event.equals(that.event) : that.event != null) return false;
        if (status != null ? !status.equals(that.status) : that.status != null) return false;
        if (modifyTime != null ? !modifyTime.equals(that.modifyTime) : that.modifyTime != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (event != null ? event.hashCode() : 0);
        result = 31 * result + (int) (totalAccount ^ (totalAccount >>> 32));
        result = 31 * result + (status != null ? status.hashCode() : 0);
        result = 31 * result + (modifyTime != null ? modifyTime.hashCode() : 0);
        return result;
    }
}
